2.3.5 Example Script for Simulation Configuration

 

1.    Configuration of PHY and channel

// *************************************** PHY and Channel ***************************************** //

  YansWifiPhyHelper wifiPhy =  YansWifiPhyHelper::Default ();

  // set it to zero; otherwise, gain will be added

  wifiPhy.Set ("RxGain", DoubleValue (0));

  wifiPhy.Set ("CcaMode1Threshold", DoubleValue (0.0));

 

  // ns-3 supports RadioTap and Prism tracing extensions for 802.11b

  wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);

 

  YansWifiChannelHelper wifiChannel;

  wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");

  wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel");

  wifiPhy.SetChannel (wifiChannel.Create ());

  // ************************************************************************************************* //

 

2.    Configuration of MAC

  // **************************************** MAC **************************************************** //

  // Add a non-QoS upper mac, and disable rate control

  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();

  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",

                                "DataMode",StringValue (phyMode),

                                "ControlMode",StringValue (phyMode));

  // Set it to adhoc mode

  wifiMac.SetType ("ns3::AdhocWifiMac");

  // ************************************************************************************************* //

 

3.    Configuration of NetDevice

// ***************************************** Net Devices ******************************************* //

  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c.Get (0), 5);

  devices.Add (wifi.Install (wifiPhy, wifiMac, c.Get(3), 1));

  // This will disable these sending devices from detecting a signal

  // so that they do not backoff

  wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (0.0) );

  wifiPhy.Set ("TxGain", DoubleValue (offset + Prss) );

  devices.Add (wifi.Install (wifiPhy, wifiMac, c.Get (1), 5));

  wifiPhy.Set ("TxGain", DoubleValue (offset + Irss) );

  devices.Add (wifi.Install (wifiPhy, wifiMac, c.Get (2), 1));

  // ************************************************************************************************* //

 

4.    Configuration of Network Topology

// **************************************** Mobility *********************************************** //

  // Note that with FixedRssLossModel, the positions below are not

  // used for received signal strength.

  MobilityHelper mobility;

  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();

  positionAlloc->Add (Vector (0.0, 0.0, 0.0));

  positionAlloc->Add (Vector (distanceToRx, 0.0, 0.0));

  positionAlloc->Add (Vector (0, -distanceToRx, 0.0));

  positionAlloc->Add(Vector (distanceToRx, -distanceToRx, 0.0));

  mobility.SetPositionAllocator (positionAlloc);

  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");

  mobility.Install (c);

  // ************************************************************************************************* //

 

Return to: Main…